﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;
using System.Threading;

namespace THenu.TinyHourseLib.DesignPattern.Abstract_Factory_Pattern
{

    public class SmartBot
    {

        public delegate void DisplayScreen(object sender, string content);
        public event DisplayScreen DisplayScreenEventHandler;
        /*
         * 选择你最希望的朋友吧：
         * 1.BeautyGirl
         * 2.FatBoy
         * 3.More chance
         * 4.Exist
         */
        private static readonly SmartBot _Singleton = new SmartBot();
        private SmartBot() { }
        public static SmartBot Singleton
        {
            get
            {
                return _Singleton;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public void CreateYourPeronalFriend()
        {
            int commond = -1;
            while (commond < 4)
            {
                Console.WriteLine(@" /*
         * 选择你最希望的朋友吧：
         * 1.BeautyGirl
         * 2.FatBoy
         * 3.More chance
         * 4.Exist
         */");
                IPersonal myFriend = null;
                string commondLine=Console.ReadLine();
                if (string.IsNullOrEmpty(commondLine))
                   break;
                commond = Convert.ToInt32(commondLine);
             
                string factoryName = string.Empty;
                if (commond == 1)
                {
                    factoryName = "THenu.TinyHourseLib.DesignPattern.Abstract_Factory_Pattern.BeautyGirl";
                }
                if (commond == 2)
                {
                    factoryName = "THenu.TinyHourseLib.DesignPattern.Abstract_Factory_Pattern.FatBoy";
                }
                if (!string.IsNullOrEmpty(factoryName))
                    myFriend = (IPersonal)Assembly.Load(factoryName).CreateInstance(factoryName);
                if (myFriend != null)
                {
                    Console.WriteLine(myFriend.Description());
                }
            }

        }
    }
}
